package com.yjy.fuyao.base.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket stuApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("stuApi")
                .apiInfo(stuApiInfo())
                .select()
                //只显示stu路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/admin/.*")))
                .build();

    }

    private ApiInfo stuApiInfo(){

        return new ApiInfoBuilder()
                .title("扶摇学院后台管理系统-API文档")
                .description("本文档描述了扶摇学院管理系统接口")
                .version("1.0")
                .contact(new Contact("yjy", "http://yjy.com", "1970475803@qq.com"))
                .build();
    }

    @Bean
    public Docket ApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("Api")
                .apiInfo(ApiInfo())
                .select()
                //只显示stu路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                .build();

    }

    private ApiInfo ApiInfo(){

        return new ApiInfoBuilder()
                .title("扶摇学院后台管理系统-API文档")
                .description("本文档描述了扶摇学院管理系统接口")
                .version("1.0")
                .contact(new Contact("yjy", "http://yjy.com", "1970475803@qq.com"))
                .build();
    }
}
